package io.kimmking.gateway.config;

import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;

import java.util.Collections;
import java.util.List;

@ConfigurationProperties(prefix = "kk.uaa")
@RefreshScope
@Setter
public class WhiteListURLConfig {

    private static List<String> ignoreUrl = Lists.newArrayList();

    @Getter
    private Boolean enable = true;

    private static final String[] ENDPOINTS = {
            "/oauth/**",
            "/actuator/**",
            "/v2/api-docs/**",
            "/v2/api-docs-ext/**",
            "/swagger/api-docs",
            "/swagger-ui.html",
            "/doc.html",
            "/swagger-resources/**",
            "/webjars/**",
            "/druid/**",
            "/error/**",
            "/assets/**",
            "/auth/logout",
            "/auth/code"
    };

    static {
        Collections.addAll(ignoreUrl, ENDPOINTS);
    }

    public List<String> getIgnoreUrl() {
        return ignoreUrl;
    }
}
